import { API_HOST , API_TIME_OUT } from "@/config/http"

export function request(method, url, data = {}) {
  return new Promise((resolve, reject) => {
    uni.request({
      method,
      url:API_HOST + url,
      data,
      header: {
        'content-type': 'application/json',
      },
	  API_TIME_OUT,
      success: (res) => {
        if (res.statusCode === 200) {
          resolve(res.data);
        } else {
          reject(new Error(res.statusCode));
        }
      },
      fail: (err) => {
        reject(err);
      },
    });
  });
}